package Thread;

public class ThreadDemo14 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("我是一个线程，正在运行");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread线程执行结束");
        });
        thread.start();
        //这个操作就是线程等待（让main等thread结束）

            thread.join();
        System.out.println("执行main线程");
    }
}
